import { _decorator, Component, instantiate, Label, Node, Sprite, SpriteFrame } from 'cc';
import { RewardItem } from '../Item/RewardItem';
const { ccclass, property } = _decorator;


export const rewardConfig = {
    ticket: { icon: 0 },
    GOLD: { icon: 1 },
    COPPER_ORE: { icon: 2, nodeName: "tong" },
    GOLD_ORE: { icon: 3, nodeName: "jin" },
    DIAMOND_ORE: { icon: 4, nodeName: "zuan" },
}

@ccclass('AdventureRewardProp')
export class AdventureRewardProp extends Component {
    @property(Node)
    rewardsNode: Node = null;
    @property(Node)
    rewardItem: Node = null;
    @property(Node)
    labelNode: Node = null;

    start() {

    }
    initPanel(data: Array<any>) {
        this.rewardsNode.removeAllChildren();
        if (data.length > 0) {
            this.labelNode.active = false;
            for (let i = 0; i < data.length; i++) {
                let item = instantiate(this.rewardItem);
                this.rewardsNode.addChild(item);
                if (!item.getComponent(RewardItem)) {
                    item.addComponent(RewardItem);
                    item.getComponent(RewardItem).init();
                }
                item.active = true;
                item.getComponent(RewardItem).setData(data[i])
            }
        } else {
            this.labelNode.active = true;
        }
    }

    update(deltaTime: number) {

    }
}


